Telegram Group & Telegram Channel
💬 В чем здесь проблема и как вы можете ее решить?

Рассмотрим этот фрагмент кода, который пытается получить цвет темы из локального хранилища устройства iOS:

var color = UserDefaults.standard.string(forKey: "themeColor")!  
print(color)


Ответ:

Первая строка извлекает цвет темы из user defaults. Этот метод, однако, возвращает optional (поскольку themeColor может быть не определен). Если ключ не найден, возвращается nil, что приводит к крашу:

fatal error: unexpectedly found nil while unwrapping an Optional value

Это происходит потому, что в первой строке используется ! для force unwrap optional, которое теперь nil. Force unwrapping должно использоваться только тогда, когда вы на 100% уверены, что значение не nil.

Чтобы исправить это, вы можете использовать optional binding для проверки, найдено ли значение для ключа:

if let color = defaults.stringForKey("themeColor") { print(color)}


🐸 Библиотека мобильного разработчика

#междусобойчик
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/mobileproglib/5822
Create:
Last Update:

💬 В чем здесь проблема и как вы можете ее решить?

Рассмотрим этот фрагмент кода, который пытается получить цвет темы из локального хранилища устройства iOS:

var color = UserDefaults.standard.string(forKey: "themeColor")!  
print(color)


Ответ:

Первая строка извлекает цвет темы из user defaults. Этот метод, однако, возвращает optional (поскольку themeColor может быть не определен). Если ключ не найден, возвращается nil, что приводит к крашу:

fatal error: unexpectedly found nil while unwrapping an Optional value

Это происходит потому, что в первой строке используется ! для force unwrap optional, которое теперь nil. Force unwrapping должно использоваться только тогда, когда вы на 100% уверены, что значение не nil.

Чтобы исправить это, вы можете использовать optional binding для проверки, найдено ли значение для ключа:

if let color = defaults.stringForKey("themeColor") { print(color)}


🐸 Библиотека мобильного разработчика

#междусобойчик

BY Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/mobileproglib/5822

View MORE
Open in Telegram


Библиотека мобильного разработчика | Android iOS Swift Retrofit Moshi Chuck Telegram | DID YOU KNOW?

Date: |

Look for Channels Online

You guessed it – the internet is your friend. A good place to start looking for Telegram channels is Reddit. This is one of the biggest sites on the internet, with millions of communities, including those from Telegram.Then, you can search one of the many dedicated websites for Telegram channel searching. One of them is telegram-group.com. This website has many categories and a really simple user interface. Another great site is telegram channels.me. It has even more channels than the previous one, and an even better user experience.These are just some of the many available websites. You can look them up online if you’re not satisfied with these two. All of these sites list only public channels. If you want to join a private channel, you’ll have to ask one of its members to invite you.

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

Библиотека мобильного разработчика | Android iOS Swift Retrofit Moshi Chuck from in


Telegram Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck
FROM USA